
    
<script setup >
import { ref } from "vue";

// 文本框内容
let query = ref("");
// 主题
let theme = ref("purple");
// 对话框
let dialogTableVisible = ref(false);
// 页面渲染内容
let list = [];

// PPT 模板数据

let subjectList = ref([]);
let res = {
  flag: true,
  code: 0,
  desc: "成功",
  count: null,
  data: [
    {
      key: "purple",
      name: "紫影幽蓝",
      thumbnail:
        "https://bjcdn.openstorage.cn/open_res/xfyundoc/2023-12-08/f5406925-fbea-498e-bfb8-af900069e659/1.png",
    },
    {
      key: "green",
      name: "清新翠绿",
      thumbnail:
        "https://bjcdn.openstorage.cn/open_res/xfyundoc/2023-12-08/dfea2504-6c84-4e72-8878-9232c7795cbf/2.png",
    },
    {
      key: "lightblue",
      name: "清逸天蓝 ",
      thumbnail:
        "https://bjcdn.openstorage.cn/open_res/xfyundoc/2023-12-08/5818984f-2f17-4814-84d0-622cc157e4cd/3.png",
    },
    {
      key: "taupe",
      name: "质感之境",
      thumbnail:
        "https://bjcdn.openstorage.cn/open_res/xfyundoc/2023-12-08/4c94360b-5b09-41a5-a16d-07a881d0e236/4.png",
    },
    {
      key: "blue",
      name: "星光夜影",
      thumbnail:
        "https://bjcdn.openstorage.cn/open_res/xfyundoc/2023-12-08/9bb5f37e-9983-4d47-abbf-0e322e964d85/5.png",
    },
    {
      key: "lightblue",
      name: "清逸天蓝 ",
      thumbnail:
        "https://bjcdn.openstorage.cn/open_res/xfyundoc/2023-12-08/5818984f-2f17-4814-84d0-622cc157e4cd/3.png",
    },
    {
      key: "taupe",
      name: "质感之境",
      thumbnail:
        "https://bjcdn.openstorage.cn/open_res/xfyundoc/2023-12-08/4c94360b-5b09-41a5-a16d-07a881d0e236/4.png",
    },
    {
      key: "blue",
      name: "星光夜影",
      thumbnail:
        "https://bjcdn.openstorage.cn/open_res/xfyundoc/2023-12-08/9bb5f37e-9983-4d47-abbf-0e322e964d85/5.png",
    },
    {
      key: "lightblue",
      name: "清逸天蓝 ",
      thumbnail:
        "https://bjcdn.openstorage.cn/open_res/xfyundoc/2023-12-08/5818984f-2f17-4814-84d0-622cc157e4cd/3.png",
    },
    {
      key: "taupe",
      name: "质感之境",
      thumbnail:
        "https://bjcdn.openstorage.cn/open_res/xfyundoc/2023-12-08/4c94360b-5b09-41a5-a16d-07a881d0e236/4.png",
    },
    {
      key: "blue",
      name: "星光夜影",
      thumbnail:
        "https://bjcdn.openstorage.cn/open_res/xfyundoc/2023-12-08/9bb5f37e-9983-4d47-abbf-0e322e964d85/5.png",
    },
    {
      key: "telecomRed",
      name: "炽热暖阳",
      thumbnail:
        "https://bjcdn.openstorage.cn/open_res/xfyundoc/2023-12-08/2477dccf-85b7-48e7-86a1-e1f574c11a36/6.png",
    },
    {
      key: "telecomGreen",
      name: "幻翠奇旅",
      thumbnail:
        "https://bjcdn.openstorage.cn/open_res/xfyundoc/2023-12-08/6c77d553-4f04-4ff6-845d-ae6e579bf8b6/7.png",
    },
    {
      key: "dragon",
      name: "龙韵新禧",
      thumbnail:
        "https://openres.xfyun.cn/xfyundoc/2024-01-23/6694baab-7e49-4e3f-8d03-eee11c0e3f5a/1705975235721/8.png",
    },
    {
      key: "bluedream",
      name: "蓝梦白翼",
      thumbnail:
        "https://openres.xfyun.cn/xfyundoc/2024-01-23/ad3b551d-5482-43d9-95ce-d4a36d1114cc/1705975293375/9.png",
    },
    {
      key: "deepdark",
      name: "墨韵金章",
      thumbnail:
        "https://openres.xfyun.cn/xfyundoc/2024-01-22/e79ed3f0-2a9e-4514-b7f6-b526b5e1699d/1705909573847/10.png",
    },
  ],
};

const submit = async () => {
  if (query.value === "") return;
  // 追加主题数据
  list.push(
    {
      title: query.value,
      // type 为1 为   文本框的数据  type2 PPT 大纲生成中
      // type3 后端返回的大纲
      type: 1,
    },
    {
      title: "PPT 大纲生成中，可以先选择模板，这两步完成后将制作 PPT~",
      type: 2,
    }
  );

  query.value = "";

  //   发送数据请求查询模板信息
  dialogTableVisible.value = true;
  subjectList.value = res.data;
  // 打开重置索引
  pptindex.value = -1;
};

// 保存颜色主题
let pptindex = ref(-1);
const savaThemes = (item, index) => {
  theme.value = item.theme;

  pptindex.value = index;
};

const pptConfirm = () => {


  if(pptindex.value  == -1) return  Me

  // 发送请求  生成ppt 

  let query = {

  }


};
const pptCancel = () => {
  dialogTableVisible.value = false;
  pptindex.value = -1;
};
</script>
 


<template>
  <div class="ppt-welcome-wrap">
    <div class="ppt-message">
      <div class="ppt-title">我将为你生成一份 PPT，可直接在下方输入主题 ：</div>
      <div class="ppt-operate-area">
        <div class="btn-wrap active">
          <i
            class="btn-icon"
            style="
              background-image: url('https://edu-wenku.bdimg.com/v1/pc/tfgenppt/ppt-theme-svg-1718337645820.svg');
            "
          ></i>
          <span class="btn-title">输入主题</span>
          <div class="btn-desc active">输入主题直接生成PPT</div>
        </div>
      </div>
    </div>
  </div>

  <div class="content" v-for="(item, index) in list" :key="index">
    <div v-if="item.type == 1" class="user-chat-bubble">{{ item.title }}</div>

    <div v-if="item.type == 2" class="message_content">{{ item.title }}</div>
  </div>

  <div class="content-area">
    <div class="user-input-wrap">
      <div class="left-wrap">
        <!---->
        <div class="top-area">
          <div class="textarea-wrap">
            <textarea
              placeholder="请输入你想创作的主题"
              autocomplete="off"
              class="user-input show-tool-tip"
              style="text-indent: 182px"
              v-model="query"
              @keydown.enter="submit"
            ></textarea>
            <span class="tool-tip" style=""> 帮我写一篇PPT，主题是： </span>
          </div>
        </div>
      </div>
    </div>

    <el-dialog
      v-model="dialogTableVisible"
      title="选择您想要的模板配色"
      width="100%"
    >
      <div class="subject-list">
        <div
          @click="savaThemes(item, index)"
          class="subject-list-box"
          v-for="(item, index) in subjectList"
          :key="index"
        >
          <img class="imgBox" :src="item.thumbnail" alt="" />
          <p>
            {{ item.name }}
          </p>

          <div v-if="pptindex == index" class="theme_selected__NlvJo">
            <svg class="" width="80px" height="80px">
              <g
                id="AI-PPT-demo版"
                stroke="none"
                stroke-width="1"
                fill="none"
                fill-rule="evenodd"
              >
                <g id="切图" transform="translate(-51.000000, -1949.000000)">
                  <g id="选中" transform="translate(51.000000, 1949.000000)">
                    <path
                      d="M40,80 C51.0456,80 61.0456,75.5228 68.2842,68.2842 C75.5228,61.0456 80,51.0456 80,40 C80,28.9544 75.5228,18.9544 68.2842,11.71572 C61.0456,4.47716 51.0456,0 40,0 C28.9544,0 18.9544,4.47716 11.71572,11.71572 C4.47716,18.9544 0,28.9544 0,40 C0,51.0456 4.47716,61.0456 11.71572,68.2842 C18.9544,75.5228 28.9544,80 40,80 Z"
                      id="路径"
                      fill="#FFFFFF"
                    ></path>
                    <path
                      d="M34,48.8245474 L22.5826537,38.2854585 C21.6357386,37.411383 20.159534,37.4704312 19.2854585,38.4173463 C18.411383,39.3642614 18.4704312,40.840466 19.4173463,41.7145415 L32.4173463,53.7145415 C33.311157,54.5395975 34.688843,54.5395975 35.5826537,53.7145415 L61.5826537,29.7145415 C62.5295688,28.840466 62.588617,27.3642614 61.7145415,26.4173463 C60.840466,25.4704312 59.3642614,25.411383 58.4173463,26.2854585 L34,48.8245474 Z"
                      id="路径"
                      fill="#426EFA"
                      fill-rule="nonzero"
                    ></path>
                  </g>
                </g>
              </g>
            </svg>
          </div>
        </div>
      </div>

      <template #footer>
        <div class="dialog-footer  my-dialog-footer">
          <el-button @click="pptCancel">取消</el-button>
          <el-button type="primary" @click="pptConfirm"> 确定 </el-button>
        </div>
      </template>
    </el-dialog>
  </div>
</template>
   
<style  scoped lang="scss">
.ppt-welcome-wrap {
  position: relative;
}

.ppt-welcome-wrap .ppt-message {
  background-color: #c1f6e6;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  margin-bottom: 16px;
  padding: 14px 0 20px 20px;
  overflow: hidden;
  border-radius: 12px;
  border-top-left-radius: 0;
  box-shadow: 0 0 24px 0 rgba(124, 168, 152, 0.1);
}

.ppt-welcome-wrap .ppt-message .ppt-title {
  font-family: "PingFang SC";
  font-style: normal;
  font-weight: 500;
  font-size: 14px;
  line-height: 22px;
  color: #1f1f1f;
  margin-bottom: 12px;
}

.ppt-welcome-wrap .ppt-message .ppt-operate-area .btn-wrap.active {
  background: rgba(33, 171, 134, 0.05);
  border-color: rgba(33, 171, 134, 0.6);
}

.btn-wrap .btn-icon {
  display: inline-block;
  width: 16px;
  height: 16px;
  background-repeat: no-repeat;
  background-size: contain;
}

.ppt-welcome-wrap .ppt-message .ppt-operate-area .btn-wrap .btn-title {
  display: inline-block;
  position: relative;
  top: -2px;
  font-family: "PingFang SC";
  font-style: normal;
  font-weight: 500;
  font-size: 16px;
  line-height: 22px;
  color: #222;
  margin-left: 6px;
}

.ppt-welcome-wrap .ppt-message .ppt-operate-area .btn-wrap .btn-desc {
  font-family: "PingFang SC";
  font-style: normal;
  font-weight: 400;
  font-size: 12px;
  line-height: 16px;
  color: #7e7e7e;
  margin-top: 3px;
}

.ppt-welcome-wrap .ppt-message .ppt-operate-area .btn-wrap {
  float: left;
  width: 194px;
  height: 75px;
  box-sizing: border-box;
  margin-right: 12px;
  padding: 18px 0 16px 20px;
  background-color: #f7f8fa;
  border-radius: 12px;
  cursor: pointer;
  border: 1.5px solid #f7f8fa;
}

.content-area {
  position: fixed;
  bottom: 20px;
  left: 0;
  box-sizing: border-box;
  width: 100%;
  height: 120px;
  padding: 2px;
  border-radius: 16px;
  background-image: linear-gradient(90deg, #1c77ff, #22af89);
  box-shadow: 0 0 12px rgba(0, 155, 109, 0.15);
}

.content-area .user-input-wrap {
  box-sizing: border-box;
  position: relative;
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  align-items: flex-start;
  padding: 8px;
  width: 100%;
  height: 100%;
  border-radius: 14px;
  background-color: #fff;
}

.content-area .user-input-wrap .left-wrap {
  box-sizing: border-box;
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: flex-start;
  height: 100%;
  padding: 2px;
}

.content-area .user-input-wrap .left-wrap .top-area {
  position: relative;
  flex-grow: 1;
  width: 100%;
}

.tools-select-wrap {
  position: absolute;
  left: -16px;
  bottom: calc(100% + 10px);
  height: auto;
  padding: 10px 10px 11px;
  display: flex;
  flex-flow: column;
  align-items: flex-start;
  background: #fff;
  border-radius: 6px;
  box-shadow: 0 0 15px 0 rgba(19, 98, 192, 0.12);
  z-index: 200;
}

.textarea-wrap .show-tool-tip {
  line-height: 26px;
}

.textarea-wrap .user-input {
  box-sizing: border-box;
  width: 100%;
  height: 100%;
  line-height: 20px;
  color: #222;
  outline: 0;
  border: none;
  overflow-y: auto;
  font-family: PingFang SC;
  font-style: normal;
  font-weight: 400;
  line-height: 24px;
  outline: none;

  text-indent: 213px !important;
}

.textarea-wrap .tool-tip {
  position: absolute;
  top: 0;
  left: 0;
  cursor: text;
  white-space: normal;
  padding-left: 10px;
  background-color: #f0f2f2;
  border-radius: 4px;
  height: 26px;
  display: flex;
  align-items: center;
  align-content: center;
  line-height: 14px;
}

.user-chat-bubble {
  border-radius: 12px;
  border-top-left-radius: 0;
  background-color: #21ab86;
  box-sizing: border-box;
  display: inline-block;
  min-height: 26px;
  padding: 9px 14px;
  word-break: break-word;
  cursor: pointer;
  white-space: initial;
  outline: none;
  font-size: 14px;
  color: #fff;
  line-height: 22px;

  margin: 10px 0;
}
.message_content {
  box-sizing: border-box;
  width: 100%;
  max-width: 100%;
  padding: 20px;
  margin-bottom: 16px;
  border-radius: 12px;
  border-top-left-radius: 0;
  background-color: #fff;
  box-shadow: 0 0 24px rgba(124, 168, 152, 0.1);
  background-color: #c0f6e6;
}
.subject-list {
  display: flex;
  flex-wrap: wrap;

}
.subject-list-box {
  text-align: center;
  border: 1px solid transparent;
  position: relative;
  margin-right: 10px;
  margin-bottom: 10px;
}
.imgBox {
  width: 286px;
  height: 163px;
}

.el-dialog:not(.is-fullscreen) {
  margin-top: 0 !important;
}

.subject-list-box:hover {
  border-color: rgb(66, 110, 250);
  box-shadow: rgba(0, 0, 0, 0.2) 0px 4px 10px 0px;
}

.theme_selected__NlvJo {
  align-items: center;
  background: rgba(0, 0, 0, 0.51);
  display: flex;
  height: 100%;
  justify-content: center;
  left: 0px;
  position: absolute;
  top: 0px;
  width: 100%;
  z-index: 100;
}

.el-dialog {
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  box-sizing: border-box;
  .subject-list {
    width: 100%;
    height: 100%;
    overflow: auto;
    box-sizing: border-box;
  }
}

::-webkit-scrollbar {
  width: 0px;
  height: 0;
}
</style>


<style   lang="scss">
.content-area {
  .el-dialog:not(.is-fullscreen) {
    margin-top: 0 !important;
  }

  .el-dialog {
    background-color: #f5f5f7;
  }
}


.my-dialog-footer {
  position: fixed;
  
  right: 0;
  bottom: 0;
  z-index: 1900000;
}
</style>